<?php
class FunctionArea{
	static function addSystemArea($areaname){
		$rs = new Result();
		if((Session::getRoleOfArea( "AreaRoot"  ) >=  (3)  ) ){
			$amng = FunctionData::readAreasManager();
			if(!FunctionData::isSystemAreaExists($areaname)){
				$amng->addSystemArea($areaname);
				FunctionData::writeAreaManager($amng);
				$aobj = new DataArea();
				$aobj->setDescription("test");
				{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
				{if( FunctionData::$static  ->get( "area_system_" .$areaname )==null) FunctionData::$static  ->set( "area_system_" .$areaname , $aobj->getBinary() );else  FunctionData::$static  ->replace( "area_system_" .$areaname , $aobj->getBinary() );} ;
				$rs->return = true;
			}else{
				$rs->addError(7 ,"Exists name");
			}
		}else{
			{Error::getInstance() ->addError( 16  , "Action not allow!"  );} ;
		}
		return $rs;
	}
	static function addUserArea($areaname){
		$rs = new Result();
		if((Session::getRoleOfArea( "AreaRoot"  ) >=  (3)  ) ){
			$amng = FunctionData::readAreasManager();
			if(!FunctionData::isUserAreaExists($areaname)){
				$amng->addUserArea($areaname);
				FunctionData::writeAreaManager($amng);
				$aobj = new DataArea();
				$aobj->setDescription("test");
				{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
				{if( FunctionData::$static  ->get( "area_user_" .$areaname )==null) FunctionData::$static  ->set( "area_user_" .$areaname , $aobj->getBinary() );else  FunctionData::$static  ->replace( "area_user_" .$areaname , $aobj->getBinary() );} ;
				$rs->return = true;
			}else{
				$rs->addError(8 ,"Exists name");
			}
		}else{
			{Error::getInstance() ->addError( 16  , "Action not allow!"  );} ;
		}
		return $rs;
	}
}
?>